print("Example script lr_shengcun.lua.");
---------------------------
----------------------------------------
local ZhenDangSheJi = CLASS(Spell)
ZhenDangSheJi.name = '震荡射击'
ZhenDangSheJi.target = 'target'
function ZhenDangSheJi:canCast()
	local t = self:getTarget()
	if t == nil then return false end

	return not immune_slowdown(t) and UnitIsPlayer(t) and GetUnitSpeed(t) >= 0
	-- return not immune_slowdown(t) 
	-- and GetUnitSpeed(t) > 0
end
----------------------------------------
local scheme = ut.newSpellQueue()

scheme.add( '夺命黑鸦', 'target', function()
    return UnitIsPlayer('target') 
end)

scheme.add('黑箭', 'target', function()
    return UnitIsPlayer('target') 
end)

scheme.add('宁神射击', 'target', function()
    return UnitIsPlayer('target') and haveStealableBuff() 
end)

scheme.add('飞刃', 'target')
scheme.add('爆炸射击', 'target')

scheme.add('奥术射击', 'target', function()
    return 	UnitBuff('player', '狩猎刺激') or UnitPower('player') > 60
end)


scheme.add('震荡射击', 'target')
scheme.add('眼镜蛇射击', 'target')

local function xianjing(name, t)
    SpellStopCasting()
    scheme.sf(function()
        SpellStopCasting()
        if not UnitExists(t) then return end
        if immune_all(t) then return end
        ut.cast(name)
        CastAtPosition(GetMidPosition('player', t, 0.55))
    end)

end
function scheme.baozha0()
    local t = 'target'
    if IsAltKeyDown() then t = PVPOther() end
    xianjing('爆炸陷阱', t)
end
function scheme.bingdong0()
    local t = 'target'
    if IsAltKeyDown() then t = PVPOther() end
    xianjing('冰冻陷阱', t)
end

function scheme.dushe0()
    local t = 'target'
    if IsAltKeyDown() then t = PVPOther() end
    xianjing('毒蛇陷阱', t)
end

function scheme.bingdong1( )
    scheme.stop()
    local t = PVPOther()
    -- xianjing('冰冻陷阱', t)
    ut.cast('冰冻陷阱')
    click(t)
end

function scheme.fanzhi()
    scheme.sf(function()
        local usable, nomana = IsUsableSpell('反制射击')
        local start, duration, enabled = GetSpellCooldown('反制射击')
        -- print(usable, start)
        if not usable or start ~= 0 then
            return false
        end

        if interruptJudge('target') then
            ut.cast('反制射击', 'target')
            return true
        end

        for i=1, 5 do
            local t = 'arena' .. i
            if UnitExists(t) then
                if interruptJudge(t) then
                    ut.cast('反制射击',t)
                    return true
                end
            else 
                break
            end
        end
    end)
end

function scheme.shufu()
    local t = 'target'
    if IsAltKeyDown() then t = PVPOther() end
    if t == nil or not UnitExists(t) then return end
    
    scheme.sf(function()
        if t == nil or not UnitExists(t) then return end
        if immune_coma(t) then return end
        SpellStopCasting()
        ut.cast('束缚射击')
        click(t)
    end)
end

function scheme.zhendang()
    SpellStopCasting()
    scheme.sf('震荡射击', 'other', function()
        SpellStopCasting()
        local t = PVPOther()
        if t == nil or not UnitExists(t) then return end
        return not immune_slowdown(t)
    end)
end

function scheme.zhaomingdan()
    scheme.sf(function()
        ut.cast('照明弹')
        click('player')
    end)
end

editWowMacro('束缚射击', [[
#showtooltip 束缚射击
/run s.shufu()
]])

editWowMacro('反制射击', [[
#showtooltip 反制射击
/run s.fanzhi()
]])

editWowMacro('震荡射击', [[
#showtooltip 震荡射击
/run s.zhendang()
]])

editWowMacro('照明弹', [[
#showtooltip 照明弹
/run s.zhaomingdan()
]])
----------------------------------------
return scheme

